cc.Class({
    extends: require('UI-PanelWindow'),

    properties: {
        tips:[cc.Node],
        btn:[cc.Node],
        coinLabel : cc.Label,
        powerLabel :cc.Label
    },
    onLoad(){
        this._super();
        this.coinGet=Math.ceil(200*(global.Data.mainArmsLevel+1)*Math.pow(1.2,global.Data.mainArmsLevel))+Math.ceil(200*(global.Data.mainArmsLevel+2)*Math.pow(1.2,global.Data.mainArmsLevel+1))+Math.ceil(200*(global.Data.mainArmsLevel+3)*Math.pow(1.2,global.Data.mainArmsLevel+2));
        /*var rc = require('RewardComponent');
        this.has = rc.hasVideo()*/
        this.coinLabel.string = global.Common.getKV(this.coinGet)
        this.powerLabel.string = global.Data.videoAdd.addPowerCount;
        global.BannerAD.createBanner('adunit-4505ca0d79fae8df');
        // if(this.has){
        //     this.btn[0].active=true;
        //     this.btn[1].active=false;
        // }else{
        //     this.btn[0].active=false;
        //     this.btn[1].active=true;
        // }
    },
    setOptions(option){
        this.option = option;
        this.tips[0].active = option == '0';
        this.tips[1].active = option == '1';
    },
    onDestroy(){
        global.BannerAD.destroy();
    },
    onClick(){
        var self = this;
        var options={
            adUnitId:'adunit-6a07e5b943279784',
            stopCb:function(){
                global.EJMgr.showToast('视频未看完，不能获得奖励')
            },
            failCb:function(){
                global.EJMgr.showToast('视频加载失败，请明天再来试试')
                self.close();
            },
            successCb:function(){
                if(self.option=='1'){
                    global.Data.goldCoin += self.coinGet;
                    self.httpGet('/game/gameUser','attrAdd',{propName: "goldCoin",count: self.coinGet},function(err,res){
                        if(!err){
                            global.EJMgr.showToast('获取金币成功')
                        }else{
                            global.Data.goldCoin -= self.coinGet
                        }
                        self.close();
                    })
                    return
                }
            }
            
        }
        global.WechatShare.video(options)
        
    },

    close(){
        
        global.BannerAD.destroy();
        global.EJMgr.popUI();
    },
});
